#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018/1/17 0017 9:23
# @Author  : Arliki
# @email   : hkdnxycz@outlook.com
# @File    : distribut_3
import queue, time
from multiprocessing.managers import BaseManager

send = queue.Queue()
receive = queue.Queue()


def get_send():
    global send
    return send


def get_receive():
    global receive
    return receive


def beg():
    BaseManager.register('get_send', callable=get_send)
    BaseManager.register('get_receive', callable=get_receive)

    manager = BaseManager(address=('127.0.0.1', 5000), authkey=b'abcd')
    manager.start()

    send = manager.get_send()
    receive = manager.get_receive()

    id = 0
    while True:
        for i in range(1, 10):
            id += 1
            print("send id=", id)
            send.put(id)
            time.sleep(1)
        while not send.empty():
            id = receive.get(10)
            print("get id=", id)
    manager.shutdown()


if __name__ == '__main__':
    beg()
